/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.dataprocessing.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.icinfo.cloud.provider.punish.dataprocessing.dto.CaseSearchDto;
import com.icinfo.cloud.provider.punish.dataprocessing.mapper.DataProcessCaseMainInfoDelRecordMapper;
import com.icinfo.cloud.provider.punish.dataprocessing.model.DataProcessCaseMainInfoDelRecord;
import com.icinfo.cloud.provider.punish.dataprocessing.service.IDataProcessCaseMainInfoDelRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseMainInfo;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import com.icinfo.framework.mybatis.mapper.entity.Example;
import com.icinfo.framework.mybatis.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述: 工单处理-案件删除备份表 data_process_case_main_info_del_record 对应的Service接口实现类.<br>
 *
 * @author framework generator
 * @date 2023年02月02日
 */
@Service
public class DataProcessCaseMainInfoDelRecordServiceImpl extends MyBatisServiceSupport implements IDataProcessCaseMainInfoDelRecordService {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(DataProcessCaseMainInfoDelRecordServiceImpl.class);

    @Autowired
    private DataProcessCaseMainInfoDelRecordMapper dataProcessCaseMainInfoDelRecordMapper;

    /**
     * 保存记录
     *
     * @param caseMainInfoDelRecord 案件删除记录
     * @author lilihao
     * @date 2023/2/8 0:52
     */
    @Override
    public void saveRecord(DataProcessCaseMainInfoDelRecord caseMainInfoDelRecord) {
        dataProcessCaseMainInfoDelRecordMapper.insert(caseMainInfoDelRecord);
    }

    /**
     * 获取删除的案件信息
     *
     * @param searchDto 查询对象
     * @return 案件信息
     * @author lilihao
     * @date 2023/2/6 18:49
     */
    @Override
    public List<DataProcessCaseMainInfoDelRecord> getCaseInfo(CaseSearchDto searchDto) {
        PageHelper.startPage(1, 10);
        Example example = new Example(DataProcessCaseMainInfoDelRecord.class);
        if (StrUtil.isNotBlank(searchDto.getId())) {
            example.createCriteria().andEqualTo("id", searchDto.getId());
        }
        if (StrUtil.isNotBlank(searchDto.getNumber())) {
            example.createCriteria().andEqualTo("caseNumber", searchDto.getNumber());
        }

        if (StrUtil.isNotBlank(searchDto.getCaseName())) {
            example.createCriteria().andLike("caseName", searchDto.getCaseName()+"%");
        }

        if (StrUtil.isNotBlank(searchDto.getCaseActsCode())) {
            example.createCriteria().andEqualTo("caseActsCode", searchDto.getCaseActsCode());
        }
        return dataProcessCaseMainInfoDelRecordMapper.selectByExample(example);
    }

    /**
     * 删除案件删除记录
     * @param id
     */
    @Override
    public void delRecord(String id) {
        dataProcessCaseMainInfoDelRecordMapper.deleteByPrimaryKey(id);
    }
}